package com.charging.business.enums;

import lombok.Getter;

/**
 * @author JerryLu
 * @date 2024/11/18 14:36
 * @description 计费模块返回值
 */
@Getter
public enum FreeModelEnumRes {
    NO_ERROR(0, "无错误"),
    PARMFILE_ABSENT(-10, "省份计费参数缺失"),
    PARMFILE_INVALID(-11, "省份计费参数存在但无效"),
    INVALID_IN_PARM(-12, "输入参数不正常"),
    APPLY_MEM_FAILED(-13, "申请内存失败"),
    INVALID_IN_PARM1(-20, "输入门架号长度不对，小于16位"),
    MENDB3LOAD_ERR1(-21, "费率数据加载失败"),
    GETFEEPLAN_ERR1(-22, "初始化查FEEPLAN表错误"),
    GETFEEPLAN_ERR2(-23, "初始化查FEEPLAN表是空表"),
    GETFESTIVALPLAN_E(-24, "读取免费计划表失败"),
    GETFEERATE_ERR1(-25, "读取GANTRY_FEE_数据失败"),
    GETFEERATE_ERR2(-26, "GANTRY_FEE_数据表为空"),
    SOPATH_OVERLENGTH(-27, "路径超长"),
    ERR61_loadFeeData(-28, "费率加载内存失败"),
    GETGANRELA_ERR1(-29, "读取GANTRY_RELATION_数据失败"),
    GETGANRELA_ERR2(-30, "GANTRY_RELATION_数据表为空"),
    CHECK_INIT_ERR1(-31, "初始化校验，费率数据指针为空"),
    CHECK_INIT_ERR2(-32, "初始化校验，免费数据指针为空"),
    CHECK_INIT_ERR3(-33, "初始化校验，费率计划指针为空"),
    CHECK_INIT_ERR4(-34, "初始化校验，门架HEX数据指针为空"),
    CHECK_INIT_ERR5(-35, "初始化校验，门架编号数据指针为空"),
    CHECK_INIT_ERR6(-36, "初始化校验，门架关联关系数据指针为空"),
    CHECK_INIT_ERR0(-37, "初始化校验，费率表中不存在当前门架编号"),
    LOADPATHPLAN_ERR39(-39, "当前门架编号错误不存在"),
    INITDJ_ERR(-40, "初始化DIJK，打开门架关系表失败号"),
    LOADPATHPLAN_ERR1(-41, "加载路径计划表PATH_PLAN失败"),
    LOADPATHPLAN_ERR2(-42, "路径计划表PATH_PLAN无数据"),
    LOADNODECODE_ERR1(-43, "加载表TOM_NodeCode_失败"),
    LOADNODECODE_ERR2(-44, "表TOM_NodeCode_无数据"),
    LOADNODECODE_ERR3(-45, "节点指针内存分配失败"),
    LOADNODECODE_ERR4(-46, "Tom_NodeRelation与TOM_NodeCode关联失败"),
    LOADNODERELATION_ERR1(-47, "加载表TOM_Relation_失败"),
    LOADNODERELATION_ERR2(-48, "表TOM_Relation_无数据"),
    LOADNODERELATION_ERR3(-49, "节点关系指针内存分配失败"),
    ERR_GETLIBVERSION_1(-50, "输入参数错误，指针长度不正确"),
    ERR_GETLIBVERSION_2(-51, "找不到版本"),
    ERR_GETFDVERSION_1(-55, "未初始化"),
    ERR_GETFDVERSION_2(-56, "输入参数错误"),
    ERR_gF_VehType1(-60, "车型输入错误"),
    ERR_gF_VehType2(-61, "找不到车型费率"),
    ERR_gF_Version_1(-62, "初始化校验失败"),
    ERR_gF_Version_2(-63, "费率计划校验失败"),
    ERR_gF_Festival_1(-64, "初始化校验失败"),
    ERR_gF_Festival_2(-65, "节假日时段计划校验失败"),
    ERR_GETFEE_0(-70, "初始化校验失败，日志保存于feeInfo2字段"),
    ERR_GETFEE_1(-71, "输入门架号长度不是19"),
    ERR_GETFEE_2(-72, "计费门架与初始化门架不一致"),
    ERR_GETFEE_3(-73, "介质类型错误"),
    ERR_GETFEE_4(-74, "车型输入错误"),
    ERR_GETFEE_5(-75, "通行时间不在费率计划范围内"),
    ERR_GETFEE_6(-76, "费额计算失败"),
    ERR_GETFEE_7(-77, "当前门架获取费率失败"),
    ERR_GETFEE_8(-78, "未找到费率版本"),
    ERR_GETFEE_9(-79, "预留"),
    ERR_GETFEE_A(-80, "预留"),
    ERR_GETFEE_B(-81, "预留"),
    ERR_GETFEE_C(-82, "预留"),
    ERR_GETFEE_D(-83, "预留"),
    ERR_GETFEE_E(-84, "预留"),
    ERR_GETFEE_F(-85, "未知错误"),
    ERR_30011(30011, "省中心计费失败"),
    ERR_30022(30022, "部中心计费失败"),
    ERR_10001(10001, "返回推算的入口信息"),
    ERR_20001(20001, "存在UJ行驶,并返回调头行驶前门架"),
    ERR_20002(20002, "根据传入的调头位置门架，返回计费结果"),
    ERR_99999(99999, "异常");

    private final Integer value;
    private final String description;

    FreeModelEnumRes(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    // 用于从字符串获取枚举实例
    public static FreeModelEnumRes fromValue(Integer value) {
        for (FreeModelEnumRes type : values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown vehicle type: " + value);
    }

}
